<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:pe="http://primefaces.org/ui/extensions">


    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:panelGroup rendered="true" >
            <h:form>
                <p:panel header="Report by Refering Doctor">
                    <f:facet name="header" >
                        <p:outputLabel value="Report by Refering Doctor"/>
                    </f:facet>


                    <h:panelGrid columns="2">
                        <h:outputLabel value="From Date"/>
                        <p:calendar id="frmDate" value="#{commonReport1.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>
                        <h:outputLabel value="To Date"/>
                        <p:calendar id="toDate" value="#{commonReport1.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>
                        <p:outputLabel value="select Bill Type" />
                        <p:selectOneRadio value="#{commonReport1.radio}">
                            <f:selectItem itemLabel="Collecting Center and OPD" itemValue="0" />
                            <f:selectItem itemLabel="Collecting Center Only" itemValue="1" />
                            <f:selectItem itemLabel="OPD Only" itemValue="2" />
                            <f:selectItem itemLabel="Inward Only" itemValue="3" />
                        </p:selectOneRadio>
                        <p:outputLabel value="Channel Doctors Only" />
                        <p:selectBooleanCheckbox value="#{commonReport1.onlyOPD}" />
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <p:commandButton value="Process"
                                         ajax="false" style="float: right;"
                                         styleClass="noPrintButton"
                                         action="#{commonReport1.listBillItemsByReferringDoctorSummery}"
                                         />
                        <p:commandButton value="Process New"
                                         ajax="false" style="float: right;"
                                         styleClass="noPrintButton"
                                         action="#{commonReport1.listBillItemsByReferringDoctorSummeryCount}"
                                         />
                        <p:commandButton ajax="false" value="Print"  styleClass="noPrintButton" style="float: right;" >
                            <p:printer target="panelPrint" />
                        </p:commandButton>
                        <p:commandButton value="Excel" ajax="false" styleClass="noPrintButton" style="float: right;">
                            <pe:exporter type="xlsx" target="tbl" fileName="Report by Referring Doctor"
                                         facetBackground="#008000" facetFontSize="15" 
                                         facetFontColor="#FFFFFF" facetFontStyle="BOLD" cellFontColor="#0000FF" cellFontSize="12"  cellFontStyle="NORMAL"  
                                         fontName="Courier New"  />
                        </p:commandButton>
                    </h:panelGrid>

                </p:panel>
                <p:panel  id="panelPrint" styleClass="noBorder summeryBorder">
                    <p:dataTable id="tbl" value="#{commonReport1.docTotals}" var="d" rowIndexVar="i"
                                 >
                        <f:facet name="header">
                            <h:outputLabel value="Requests by Referring Doctor "/>
                            <p:outputLabel value=" - #{commonReport1.referringDoctor.person.name}" rendered="#{commonReport1.referringDoctor ne null}" />
                            <br></br>
                            <h:outputLabel value="From " />
                            <h:outputLabel  value="#{commonReport1.fromDate}">
                                <f:convertDateTime pattern="yyyy MM dd hh:mm:ss a"/>
                            </h:outputLabel>
                            <h:outputLabel value=" - " />
                            <h:outputLabel value="#{commonReport1.toDate}">
                                <f:convertDateTime pattern="yyyy MM dd hh:mm:ss a"/>
                            </h:outputLabel>
                        </f:facet>

                        <p:column >
                            <f:facet name="header">
                                <h:outputLabel value="No"/>
                            </f:facet>
                            <h:outputLabel value="#{i+1}" rendered="#{d.doctor ne null}"/>
                            <h:outputLabel value="Total" rendered="#{d.doctor eq null}" style="font-weight: bold;"/>
<!--                            <f:facet name="footer">
                                <h:outputLabel value="Total"/>
                            </f:facet>-->
                        </p:column>

                        <p:column >
                            <f:facet name="header">
                                <h:outputLabel value="Referring Doctor" />
                            </f:facet>
                            <h:outputLabel value="#{d.doctor.person.name}" rendered="#{d.doctor ne null}"/>
                        </p:column>


                        <p:column styleClass="numberCol" sortBy="#{d.count}">
                            <f:facet name="header">
                                <h:outputLabel value="Count"/>
                            </f:facet>
                            <h:outputLabel value="#{d.count}" style="font-weight: #{d.doctor eq null ? 'Bold':''};">
                                <f:convertNumber pattern="#,###,##0" />
                            </h:outputLabel>
<!--                            <f:facet name="footer">
                                <h:outputLabel  value="#{commonReport1.biledBillsTotal}" style="float: right;">
                                    <f:convertNumber pattern="#,###,##0.00" />
                                </h:outputLabel>
                            </f:facet>-->
                        </p:column>
                        <p:column styleClass="numberCol"  sortBy="#{d.total}">
                            <f:facet name="header">
                                <h:outputLabel value="Net Value"/>
                            </f:facet>
                            <h:outputLabel value="#{d.total}" style="font-weight: #{d.doctor eq null ? 'Bold':''};">
                                <f:convertNumber pattern="#,###,##0.00" />
                            </h:outputLabel>
<!--                            <f:facet name="footer">
                                <h:outputLabel  value="#{commonReport1.biledBillsTotal}" style="float: right;">
                                    <f:convertNumber pattern="#,###,##0.00" />
                                </h:outputLabel>
                            </f:facet>-->
                        </p:column>
                    </p:dataTable>
                </p:panel>        
            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
